class GalleryTemplate < ActiveRecord::Base
  has_many                  :galleries
  validates_presence_of     :name
  #validates_presence_of     :handles_add_to_cart
  #validates_presence_of     :handles_proofing
  #validates_presence_of     :handles_photos
  #validates_presence_of     :handles_videos
  
  before_destroy            :reassign_affected_galleries
  
protected
  def reassign_orphanined_galleries_and_photo_sizes
    self.galleries.each {|gallery| gallery.update_attributes!(:gallery_template => GalleryTemplate.find(:all).first)} unless GalleryTemplate.find(:all).empty?
  end
end